package com.zzy.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.stream.binding.BinderAwareChannelResolver;
//import org.springframework.messaging.MessageChannel;
//import org.springframework.messaging.MessageHeaders;
//import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import org.springframework.util.MimeTypeUtils;

/**
 * Created with IntelliJ IDEA.
 * @author : sunxuesong
 * Date: 2019/3/12
 * Time: 上午11:16
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@Service
public class WarningService {
    /*private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private BinderAwareChannelResolver resolver;

    *//**
     * 发送预警消息到指定topic，这里的topic是由平台编码+平台名称组成
     * 若发现kafka中没有该topic，它会自动创建一个由平台编码+平台名称组成的topic
     * @param warnings
     * @param topic
     * @return
     *//*
    public String sendWarning(final Msg warnings, String topic) {
        logger.info("Sending warnings {}", warnings);

        // 获取预警的topic，然后发送预警消息到kafka的topic
        MessageChannel messageChannel = resolver.resolveDestination(topic);
        messageChannel.send(MessageBuilder
                .withPayload(warnings)
                .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
                .build());

        return "send msg ok";
    }

    *//**
     * 发送布控消息到指定topic，这里的topic是由平台编码+平台名称组成
     * 若发现kafka中没有该topic，它会自动创建一个由平台编码+平台名称组成的topic
     * @param msg
     * @param topic
     * @return
     *//*
    public String sendControl(final Msg msg, String topic) {
        logger.info("Sending controlMsg {}", msg);
        // 获取布控的topic，然后发送布控消息到kafka的topic
        MessageChannel messageChannel = resolver.resolveDestination(topic);
        messageChannel.send(MessageBuilder
                .withPayload(msg)
                .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
                .build());

        return "send msg ok";
    }*/
}